import 'dart:convert';

import 'package:bruno/bruno.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intl/intl.dart';
import 'package:sph_shipper/AppConfig/ShowDialog.dart';
import 'package:sph_shipper/FandCar/DesignatedDriverView.dart';
import 'package:sph_shipper/SendGoods/ECargoInsurance.dart';

import '../AppConfig/Config.dart';
import '../AppConfig/LocalStorage.dart';
import '../AppConfig/RouteAct.dart';
import '../Main/ProtocolDisplay.dart';
import '../TabBar/TabbarView.dart';
import '../http/NoLoadingGetApi.dart';
import '../http/api.dart';
import '../l10n/messages.dart';
import 'PayInsurancePremiums.dart';
import 'PaymentCycleSheet.dart';

class PerfectGoods extends StatefulWidget {
  const PerfectGoods({super.key, required this.goodsList, required this.editType, required this.dataMap});
  final Map goodsList;
  final Map dataMap;
  final int editType;

  @override
  State<PerfectGoods> createState() => _PerfectGoodsState();
}

class _PerfectGoodsState extends State<PerfectGoods> {

  List chooseTimeList=["全天都可以","凌晨 00:00-6:00","上午 06:00-12:00","下午 12:00-18:00","晚上 18:00-24:00"
    ,"00:00-02:00","02:00-:04:00","04:00-06:00","06:00-08:00","08:00-10:00","10:00-12:00","12:00-14:00",
    "14:00-16:00","16:00-18:00","18:00-20:00","20:00-22:00","22:00-24:00"];
  List timeCodeList=["0,24","0,6","6,12","12,18","18,24","0,2","2,4","4,6","6,8","8,10","10,12","12,14","14,16","16,18","18,20","20,22","22,24"];
  List<String> remarkList = ['到付', '带雨布', ];
  List<String> despoitTypeList=["退还","不退还"];

  String remarkStr ="";
  String isAgree ="0";
  int payType =1;
  String startTimeDay="";
  String startTimeHour="";
  String startTimeCode="";
  String endTimeDay="";
  String endTimeHour="";
  String endTimeCode="";
  int alertCheck=1;
  bool isChooseInsure=false;
  bool showMoreInsure=false;
  String MyBid ="";
  String depositNum="";
  int depositType=0;
  String shipperId="";
  int BidType=0;
  List insureMsgList=[];
  List insureList=[{"id":"1","title":"货运险","subtitleStart":"最高300万保障","subtitleEnd":"交通事故、火灾爆炸、暴雨都可保","rates":"0.0003",}];
  int editInsureType=0;
  String insuranceld="";
  String companyId="";
  String orgId="";
  int payPeriod=802;
  String dayStr="";
  String payTitle="到付";
  String payPeriodStr="";
  late TextEditingController _depositNumText = TextEditingController(text:depositNum );
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserInfo();
    if (widget.editType!=1){
      if (widget.dataMap['remark']!=null)
      remarkStr =widget.dataMap['remark'];
      if (widget.dataMap['deposit']!=null)
      depositNum =(widget.dataMap['deposit']).toString();
      // if (widget.dataMap['depositType']!=null)
      // depositType =widget.dataMap['depositType'];
      if (widget.dataMap['freight']!=null)
      MyBid =(widget.dataMap['freight']).toString();
      if (widget.dataMap['type']!=null)
      payType =widget.dataMap['type']+1;
      if (widget.dataMap['shipperId']!=null)
      shipperId =widget.dataMap['shipperId'];
      if(widget.dataMap['loadTime']!=null&&widget.editType==2){
        RegExp regex = RegExp(r'\b\d{4}\b');
        Match? match = regex.firstMatch(widget.dataMap['loadDay']);
        if (match != null) {
          startTimeDay=widget.dataMap['loadDay'].substring(5);
        }else{
          startTimeDay=widget.dataMap['loadDay'];
        }

        int index = timeCodeList.indexOf(widget.dataMap['loadTime'].replaceAll("-",","));
        print(index);
        if (index != -1) {
          startTimeHour=chooseTimeList[index];
        }else{
          startTimeHour=widget.dataMap['loadTime'];
        }
        startTimeCode=widget.dataMap['loadTime'].replaceAll("-",",");
      }
      if(widget.dataMap['unloadTime']!=null&&widget.editType==2){
        RegExp regex = RegExp(r'\b\d{4}\b');
        Match? match = regex.firstMatch(widget.dataMap['unloadDay']);
        if (match != null) {
          endTimeDay=widget.dataMap['unloadDay'].substring(5);
        }else{
          endTimeDay=widget.dataMap['unloadDay'];
        }
        int index = timeCodeList.indexOf(widget.dataMap['unloadTime'].replaceAll("-",","));
        print(index);
        if (index != -1) {
          endTimeHour=chooseTimeList[index];
        }else{
          endTimeHour=widget.dataMap['unloadTime'];
        }

        endTimeCode=widget.dataMap['unloadTime'].replaceAll("-",",");
      }

      // if(widget.editType==2){
      //   getDetailsAction(widget.dataMap['id']);
      // }
      if(widget.dataMap['goodsInsurance']!=null){
        insureMsgList=[];
        isChooseInsure=false;
        insuranceld=widget.dataMap['goodsInsurance'][0]['insuranceId'];
        insureMsgList.add(widget.dataMap['goodsInsurance'][0]['goodsAmount']+"元");
        insureMsgList.add(widget.dataMap['goodsInsurance'][0]['policyholderName']);
        insureMsgList.add(widget.dataMap['goodsInsurance'][0]['insurerName']);
        if(widget.dataMap['goodsInsurance'][0]['insurerIdCard']!=null){
          insureMsgList.add(widget.dataMap['goodsInsurance'][0]['insurerIdCard']);
        }else{
          insureMsgList.add("--");
        }
      }

    }

    // getinsureMessage();
  }
  void getUserInfo(){
    NoLoadinggetApiManager.getData(
      context,
      MyServiceUrl.getLoginUser,
      {},
          (responseData)  {

          setState(() {
            if(responseData['data']['companyId']!=null) {
              companyId = responseData['data']['companyId'];
              orgId = responseData['data']['orgId']==null?"":responseData['data']['orgId'];
            }
          });

      },
    );
  }
  //获取保险列表
  void getinsureMessage() async {
    String? token= await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));

    dio.get<String>(MyServiceUrl.header+'api/system/dev/insurance/page?current=1&size=20')
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());

        // 获取code和data
        String code = jsonMap['code'].toString();
        if (code == "200") {
          setState(() {
            insureList=jsonMap['data']['records'];
          });
        } else {}
        // 打印结果
        print('Code: $code');
      });
    }).catchError((error) {
      print(error);
    });
  }

  //获取货源详情
  void getDetailsAction(String id) async {
    NoLoadinggetApiManager.getData(
      context,
      MyServiceUrl.goodsdetail,
      {
        "id":id,
      },
          (responseData) async {
        setState(() {
          // isChooseInsure=false;
          // insuranceld=responseData['data']['goodsInsurance'][0]['insuranceld'];
          // insureMsgList.add(responseData['data']['goodsInsurance'][0]['goodsAmount']+"元");
          // insureMsgList.add(responseData['data']['goodsInsurance'][0]['policyholderName']);
          // insureMsgList.add(responseData['data']['goodsInsurance'][0]['insurerName']);
          // if(responseData['data']['goodsInsurance'][0]['insurerIdCard']!=null){
          //   insureMsgList.add(responseData['data']['goodsInsurance'][0]['insurerIdCard']);
          // }else{
          //   insureMsgList.add("--");
          // }
        });

      },
    );


  }
  FocusNode _focusNode = FocusNode();
  void _handleTap() {
    if (_focusNode.hasFocus) {
      _focusNode.unfocus();
    }
  }
  @override
  void dispose() {
    _focusNode.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    var messages = AppLocalizations.of(context)!;


    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
          leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        centerTitle: true,
        backgroundColor: Colors.white,
        title: Text("完善货源信息",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w300),),
      ),
      body: GestureDetector(onTap: _handleTap,child:  Column(
        children: [
          Expanded(child: ListView(
            children: [
              GestureDetector(
                child:  Container(
                  margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                  padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          Text("*",style: TextStyle(color: MyColors.themeColor),),
                          Text("装货时间",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        ],
                      ),
                      Row(
                        children: [
                          startTimeDay!=""&&startTimeHour!=""?
                          Text(startTimeDay+" "+startTimeHour,style: TextStyle(color: Colors.black,fontSize: 13.sp),):
                          Text("必填，请选择装货时间",style: TextStyle(color: MyColors.hintColor,fontSize: 13.sp),),
                          Icon(Icons.arrow_forward_ios,color: MyColors.hintColor,size: 14,),
                        ],
                      ) ,
                    ],
                  ),
                ),
                onTap: ()async{
                  final result = await  showModalBottomSheet(context: context,
                      isScrollControlled:true,
                      isDismissible: false, // 设置为 false，点击外部区域不关闭
                      enableDrag: false, // 设置为 false，禁用上滑手势关闭
                      builder: (BuildContext context)
                      {
                        return  ChooseTimeSheet(chooseTimeType: 1, timeDay: startTimeDay, timeHour: startTimeHour, timeCode: startTimeCode,);
                      });
                  if (result != null) {
                    setState(() {
                      startTimeDay = result[0];
                      startTimeHour = result[1];
                      startTimeCode =result[2];
                    });
                  }
                },
              ),

              GestureDetector(
                  child:  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
                    decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.all(Radius.circular(10))),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: Colors.white),),
                            Text("卸货时间",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          ],
                        ),

                        Row(
                          children: [
                            endTimeDay!=""&&endTimeHour!=""?
                            Text(endTimeDay+" "+endTimeHour,style: TextStyle(color: Colors.black,fontSize: 13.sp),):
                            Text("选填，请选择卸货时间",style: TextStyle(color: MyColors.hintColor,fontSize: 13.sp),),
                            Icon(Icons.arrow_forward_ios,color: MyColors.hintColor,size: 14,),
                          ],
                        ) ,

                      ],
                    ),
                  ),
                  onTap: ()async {
                    final result = await showModalBottomSheet(context: context,
                        isScrollControlled: true,
                        isDismissible: false,
                        // 设置为 false，点击外部区域不关闭
                        enableDrag: false,
                        // 设置为 false，禁用上滑手势关闭
                        builder: (BuildContext context) {
                          return ChooseTimeSheet(chooseTimeType: 2,
                            timeDay: endTimeDay,
                            timeHour: endTimeHour,
                            timeCode: endTimeCode,);
                        });
                    if (result != null) {
                      setState(() {
                        endTimeDay = result[0];
                        endTimeHour = result[1];
                        endTimeCode = result[2];
                      });
                    }
                  }
              ),
              GestureDetector(
                child:   Container(
                  margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                  padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10))),
                  child: Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Row(
                            children: [
                              Text("*",style: TextStyle(color: Colors.white),),
                              Text("备注",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                            ],
                          ),
                          Row(
                            children: [

                              remarkStr==""?
                              Text("选填，填写可防治司机误抢",style: TextStyle(color: MyColors.hintColor,fontSize: 14.sp),)
                                  : Container(
                                width: 200.w,
                                child:Text(remarkStr,style: TextStyle(color: Colors.black,fontSize: 13.sp), overflow: TextOverflow.ellipsis,textAlign: TextAlign.right ),
                              ),
                              Icon(Icons.arrow_forward_ios,color: MyColors.hintColor,size: 14,),
                            ],
                          ) ,
                        ],
                      ),

                    ],
                  ),
                ),
                onTap: ()async{
                  final result = await  showModalBottomSheet(context: context,
                      isScrollControlled:true,
                      isDismissible: false, // 设置为 false，点击外部区域不关闭
                      enableDrag: false, // 设置为 false，禁用上滑手势关闭
                      builder: (BuildContext context)
                      {
                        return  RemarkMessageSheet(remarkStr: remarkStr,);
                      });
                  if (result != null) {
                    setState(() {
                      remarkStr =result;
                    });
                  }
                },
              ),

              Container(
                margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.all(Radius.circular(10))),
                child: Column(
                  children: [
                    Row(
                      // crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text("订金",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        // SizedBox(width: 8.w,),
                        Container(
                          width: 120.w,
                          height: 30.h,
                          child:  TextField(
                              focusNode: _focusNode,
                            controller: _depositNumText,
                            decoration: InputDecoration(
                              hintText: '选填，20-1000元',
                              // labelText:widget.editType==1?"":depositNum ,
                              hintStyle:TextStyle(fontSize: 13.sp,color: MyColors.hintColor),
                              filled: true,
                              fillColor: Colors.white,
                              border: InputBorder.none,
                              alignLabelWithHint: true,
                              // contentPadding: EdgeInsets.symmetric(vertical: 8.5.h, horizontal: 0.0.w),
                            ),
                            keyboardType: TextInputType.number,
                            textAlign: TextAlign.left,
                            style: TextStyle(color: Colors.black,fontSize: 14.sp),
                            onChanged: (value) {
                              setState(() {
                                depositNum=value;
                                print(value);
                              });
                            },
                          ),
                        ),

                        Text("元",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        BrnSmallMainButton(
                          title: '退还',
                          width: 50.w,
                          fontSize: 12.sp,
                          bgColor: depositType!=0?MyColors.backgreyColor:Color(0XFFFBECE4),
                          textColor: depositType==0?MyColors.themeColor:Colors.black,
                          onTap: () {
                            setState(() {
                              depositType=0;
                            });
                          },
                        ),
                        BrnSmallMainButton(
                          title: '不退还',
                          fontSize: 12.sp,
                          width: 50.w,
                          bgColor: depositType!=1?MyColors.backgreyColor:Color(0XFFFBECE4),
                          textColor: depositType==1?MyColors.themeColor:Colors.black,
                          onTap: () {
                            setState(() {
                              depositType=1;
                            });
                          },
                        ),
                      ],
                    ),
                    SizedBox(height: 15.h,),
                    Container(
                      padding: EdgeInsets.only(top: 6.h,bottom: 6.h,left: 10.w,right: 10.w),
                      decoration: BoxDecoration(
                          color: Color.fromRGBO(251, 241, 233, 1),
                          borderRadius: BorderRadius.all(Radius.circular(10))),
                      child:  RichText(
                        text: TextSpan(
                          text: '司机支付订金到平台用于订货押金，您收货后，退还给司机 ',
                          style: TextStyle(color: MyColors.themeColor,fontSize: 10.sp),
                          children: <TextSpan>[
                            TextSpan(
                              text: '查看流程 >',
                              style: TextStyle(
                                  color: Colors.blue,fontSize: 10.sp
                              ),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  showDialog(
                                      context: context,
                                      builder: (BuildContext context) {
                                        return DespoitAlertShow();
                                      }
                                  );
                                },
                            ),
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              GestureDetector(
                  child:Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
                    decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.all(Radius.circular(10))),
                    child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children:[
                          Row(
                            children: [
                              Text("*",style:TextStyle(color:MyColors.themeColor,fontSize: 14.sp)),
                              Text("付款周期",style:TextStyle(color: Colors.black,fontSize: 14.sp)),
                            ],
                          ),

                          Row(
                            children:[
                              if(payPeriod==-1&&dayStr=="")
                              Text("请选择周期",style:TextStyle(color:MyColors.hintColor,fontSize: 14.sp )),
                              if(dayStr!="")
                                Text("货到"+dayStr+"天后付",style:TextStyle(color:Colors.black,fontSize: 14.sp )),
                              if(payPeriod!=-1)
                                Text(payTitle,style:TextStyle(color:Colors.black,fontSize: 14.sp )),
                              Icon(Icons.arrow_forward_ios,size: 14,color:MyColors.hintColor,)
                            ]
                          )
                        ]
                    ),
                  ),
                onTap: ()async{
                  final result=await showModalBottomSheet(context: context, builder: (BuildContext context) {
                    return PaymentCycleSheet(payPeriod: payPeriod, payPeriodStr:payTitle, dayStr: dayStr,
                    );});
                    if(result!=null){
                      setState(() {
                        payPeriod=result[0];
                        dayStr=result[1];
                        payTitle=result[2];
                      });

                    }
                },
              ),

              // Container(
              //   margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
              //   padding: EdgeInsets.only(top: 10.h,bottom: 10.h,left: 15.w,right: 15.w),
              //   decoration: BoxDecoration(
              //       color: Colors.white,
              //       borderRadius: BorderRadius.all(Radius.circular(10))),
              //   child: Column(
              //     children: [
              //       Row(
              //         mainAxisAlignment: MainAxisAlignment.spaceBetween,
              //         children: [
              //           Row(
              //             children: [
              //               Image.asset("lib/Images/OrderList/完善货源保险icon.png",width: 20.w,height: 20.h,),
              //               Text("保险",style: TextStyle(color: MyColors.themeColor,fontWeight: FontWeight.w600,fontSize: 14.sp),),
              //               SizedBox(width: 4.w,),
              //               BrnTagCustom.buildBorderTag(
              //                 tagText: '司机未接单，保费自动退',
              //                 textColor: MyColors.themeColor,
              //                 borderColor: MyColors.themeColor,
              //                 borderWidth: 1.h,
              //                 fontSize: 12.sp,
              //               ),
              //             ],
              //           ),
              //           IconButton(onPressed: (){
              //             setState(() {
              //               isChooseInsure=!isChooseInsure;
              //             });
              //           }, icon:isChooseInsure? Icon(Icons.check_circle,color: MyColors.themeColor,):Icon(Icons.radio_button_off,color: MyColors.textColor,)),
              //         ],
              //       ),
              //       Row(
              //         children: [
              //           Text(insureList[0]['title'],style: TextStyle(color: Colors.black,fontSize: 12.sp),),
              //           Text(insureList[0]['subtitleStart']+","+insureList[0]['subtitleEnd'],style: TextStyle(color: MyColors.textColor,fontSize: 10.sp),),
              //         ],
              //       ),
              //       if (isChooseInsure&&insureMsgList.length<1)
              //         GestureDetector(
              //           child:   Container(
              //             color: Color.fromRGBO(248, 248, 248, 1),
              //             height: 45.h,
              //             child: Center(child: Text("+添加被保人",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),),
              //           ),
              //           onTap: () async{
              //             final result =await   Navigator.push(context,
              //                 MaterialPageRoute(builder: (context) {
              //                   return ECargoInsurance(insureList: insureMsgList,
              //                   );
              //                 }));
              //             if (result != null){
              //               print(result);
              //               setState(() {
              //                 insureMsgList=result;
              //
              //               });
              //
              //             }
              //           },
              //         ),
              //       if (isChooseInsure&&insureMsgList.length>0)
              //         Container(
              //           padding: EdgeInsets.only(left: 15.w,right: 10.w,top: 8.h,bottom: 8.h),
              //           decoration: BoxDecoration(
              //               color: MyColors.backgreyColor,
              //               borderRadius: BorderRadius.all(Radius.circular(10))),
              //           child: Row(
              //             crossAxisAlignment: CrossAxisAlignment.center,
              //             mainAxisAlignment: MainAxisAlignment.spaceBetween,
              //             children: [
              //               Column(
              //                 crossAxisAlignment: CrossAxisAlignment.start,
              //                 children: [
              //                   Text("货物价值（保额）："+ insureMsgList[0],style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
              //                   Text("保险支付方（投保人）：${insureMsgList[1][0]}",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
              //                   Text("被保人："+ insureMsgList[2][0],style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
              //                   Text("被保人证件号码："+ insureMsgList[2][1],style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
              //                 ],
              //               ),
              //               TextButton(onPressed: ()async{
              //                 final result =await   Navigator.push(context,
              //                     MaterialPageRoute(builder: (context) {
              //                       return ECargoInsurance(insureList: insureMsgList,
              //                       );
              //                     }));
              //                 if (result != null){
              //                   print(result);
              //                   setState(() {
              //                     insureMsgList=result;
              //                     if(widget.editType==2){
              //                       editInsureType=1;
              //                     }
              //                   });
              //
              //                 }
              //               }, child: Text("修改",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),)),
              //             ],
              //           ),
              //         ),
              //       if (isChooseInsure&&insureList.length>1)
              //         GestureDetector(
              //           child: Row(
              //             mainAxisAlignment: MainAxisAlignment.end,
              //             children: [
              //               Text(showMoreInsure?"收起":'展开',style: TextStyle(color: Colors.black),),
              //               Icon(showMoreInsure?Icons.keyboard_arrow_up :Icons.keyboard_arrow_down,color: MyColors.authTipColor,),
              //             ],
              //           ),
              //           onTap: (){
              //             setState(() {
              //               showMoreInsure =!showMoreInsure;
              //             });
              //           },
              //         ),
              //     ],
              //   ),
              // ),
              Container(
                margin: EdgeInsets.only(left: 10.w,right: 10.w),
                color: Color.fromRGBO(239, 239, 239, 1),
                height:showMoreInsure? 120.h :0.0,
                child:Column(
                  children: [
                    Container(
                        padding:EdgeInsets.only(left: 11.w,top: 10.h,right: 9.w,bottom: 10.h),
                        margin: EdgeInsets.only(left: 16.w,right: 16.w,top: 8.h),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(10),
                          color:Colors.white,
                        ),
                        child:Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    Text("驾乘意外险",style: TextStyle(color: Colors.black,fontSize: 12.sp)),
                                    SizedBox(width: 8.w,),
                                    Text("XXXXXXXXXXX，可保多少万",style: TextStyle(color: MyColors.hintColor,fontSize: 10.sp),),
                                  ],
                                ),
                                GestureDetector(
                                  child: Icon(Icons.radio_button_unchecked,color: MyColors.authTipColor,size: 20,),
                                  onTap: (){

                                  },
                                ),
                              ],
                            ),
                            SizedBox(height: 8.h,),
                            Container(
                              color: Color.fromRGBO(248, 248, 248, 1),
                              height: 45.h,
                              child: Center(child: Text("+添加被保人",style: TextStyle(color: MyColors.textColor),),),
                            ),
                          ],
                        )

                    ),

                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(left: 10.w, right: 10.w),
                child: Row(

                  children: [
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        IconButton(
                          onPressed: () => {
                            setState(() {
                              if (isAgree == "1") {
                                isAgree = "0";
                              } else {
                                isAgree = "1";
                              }
                            })
                          },
                          icon:isAgree == "0" ? Icon(Icons.radio_button_unchecked,size: 20,): Icon(Icons.radio_button_checked),
                          color: isAgree == "1" ? Colors.orange : Colors.grey,
                        ),
                        SizedBox(height: 15.h,),
                      ],
                    ),
                    Container(
                      width: 290.w,
                      child:  RichText(
                        text: TextSpan(children: [
                          TextSpan(
                              text: '已阅读并同意 ',
                              style: TextStyle(fontSize: 12.sp, color: Colors.black54,)),
                          TextSpan(
                              text: '《货物运输技术服务协议》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  Navigator.push( context, FadeRoute(page:ProtocolDisplay(id: "1805852208060960770",)));
                                }),
                          TextSpan(
                              text: '《货物运输协议》',
                              style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  Navigator.push( context, FadeRoute(page:ProtocolDisplay(id: "1805851815423774721",)));
                                }),

                          // TextSpan(
                          //     text: '《开票货源发货权限管理规则》',
                          //     style: TextStyle(fontSize: 12.sp, color: Colors.blue),
                          //     recognizer: TapGestureRecognizer()
                          //       ..onTap = () {
                          //         // 查看 服务条款
                          //       }),

                        ]),
                      ),
                    ),

                  ],
                ),

              ),

            ],
          ),
          ),
          Container(
            padding: EdgeInsets.only(top: 15.h,left: 15.w,right: 15.w,bottom: 44.h),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Column(
              children: [
                GestureDetector(
                  onTap: ()async{
                    final result = await  showModalBottomSheet(context: context,
                        isScrollControlled:true,
                        isDismissible: false, // 设置为 false，点击外部区域不关闭
                        enableDrag: false, // 设置为 false，禁用上滑手势关闭
                        builder: (BuildContext context)
                        {
                          return  MyBidSheet(goodsWeight: widget.goodsList['cargoInfo'][0]['cargoWeight'], goodsValume:widget.goodsList['cargoInfo'][0]['cargoVolume'], freight: MyBid, BidType: BidType,);

                        }
                    );
                    if (result != null) {
                      setState(() {
                        MyBid = result[0];
                        BidType=result[1];
                      });
                    }
                  },
                  child: Container(
                    padding: EdgeInsets.only(top: 5.h,left: 15.w,right: 15.w,bottom: 5.h),
                    height: 44.h,
                    decoration: BoxDecoration(
                        color: MyColors.backgreyColor,
                        borderRadius: BorderRadius.all(Radius.circular(10))),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Text("我的出价",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                            Text("丨",style: TextStyle(color: MyColors.hintColor),),
                            Text(MyBid!=""? MyBid :"选填，请输入总价",style: TextStyle(color:MyBid!=""?Colors.black: MyColors.hintColor,fontSize: 14.sp),)
                          ],
                        ),

                        Text(BidType==0?"元/趟":BidType==2?"元/吨":"元/方",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                      ],
                    ),
                  ),
                ),

                SizedBox(height: 8.h,),
                Row(
                  children: [
                    Image.asset("lib/Images/OrderList/完善货源大拇指icon.png",width: 18.w,height: 18.h,),
                    Text("使用一口价，将货一键优推给司机，更快成单",style: TextStyle(color: MyColors.themeColor,fontSize: 12.sp),),
                  ],
                ),
                SizedBox(height: 4.h,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    GestureDetector(
                      child: Container(
                        width: screenSize.width/2,
                        decoration: BoxDecoration(
                            color:payType==1?Color.fromRGBO(251, 236, 228, 1): MyColors.backgreyColor,
                            borderRadius: BorderRadius.all(Radius.circular(10))),
                        child: Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                BrnTagCustom(
                                  tagText: '推荐',
                                  fontSize: 12.sp,
                                  backgroundColor: MyColors.themeColor,
                                  tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomRight:Radius.circular(5) ),
                                ),
                                BrnTagCustom(
                                  tagText: '✓',
                                  fontSize: 10.sp,
                                  backgroundColor: payType==1? MyColors.themeColor:MyColors.hintColor,
                                  tagBorderRadius: BorderRadius.only(topRight: Radius.circular(5),bottomLeft:Radius.circular(5) ),
                                ),
                              ],
                            ),
                            Center(
                              child: Text("一口价",style: TextStyle(color:payType==1?MyColors.themeColor: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                            ),
                            SizedBox(height: 10.h,),
                          ],
                        ),
                      ),
                      onTap: (){
                        setState(() {
                          payType=1;
                        });
                      },
                    ),
                    GestureDetector(
                      child: Container(
                        width: screenSize.width/3,
                        decoration: BoxDecoration(
                            color: payType==2?Color.fromRGBO(251, 236, 228, 1): MyColors.backgreyColor,
                            borderRadius: BorderRadius.all(Radius.circular(10))),
                        child: Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.end,
                              children: [
                                BrnTagCustom(
                                  tagText: '✓',
                                  fontSize: 12.sp,
                                  backgroundColor:payType==2? MyColors.themeColor:MyColors.hintColor,
                                  tagBorderRadius: BorderRadius.only(topRight: Radius.circular(5),bottomLeft:Radius.circular(5) ),
                                ),
                              ],
                            ),
                            Center(
                              child: Text("电议",style: TextStyle(color: payType==2?MyColors.themeColor: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                            ),
                            SizedBox(height: 10.h,),
                          ],
                        ),
                      ),
                      onTap: (){
                        setState(() {
                          payType=2;
                        });
                      },
                    ),
                  ],
                ),
                SizedBox(height: 12.h,),

                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    if(widget.editType==1||widget.editType==3)
                      BrnSmallOutlineButton(
                        title: '指派司机',
                        textColor: MyColors.themeColor,
                        lineColor:  MyColors.themeColor,
                        radius: 30,
                        fontSize: 14.sp,
                        width: 150.w,
                        onTap: () {
                          if (startTimeDay == "") {
                          BrnToast.show("请选择装货时间", context);
                        } else if (isAgree == "0") {
                          BrnToast.show("请阅读并同意协议信息", context);
                        } else if (payType == -1) {
                          BrnToast.show("请选择货源类型", context);
                        } else if (payType == 2) {
                          BrnToast.show("电议货源无法指派司机", context);
                        } else if (payType == 1 && MyBid == "") {
                          BrnToast.show("请输入运费金额", context);
                        } else {
                            if(MyBid!="")payType=1;
                            List loadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['loadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['loadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['loadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['loadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['loadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['loadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['loadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['loadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['loadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['loadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['loadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['loadPlaceInfo'].length==2){
                              loadPlaceInfo.add({
                                "province": widget.goodsList['loadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['loadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['loadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['loadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['loadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['loadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['loadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['loadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['loadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['loadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['loadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            List unloadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['unloadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['unloadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['unloadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['unloadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['unloadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['unloadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['unloadPlaceInfo'].length==2){
                              unloadPlaceInfo.add({
                                "province": widget.goodsList['unloadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['unloadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['unloadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['unloadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['unloadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['unloadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['unloadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['unloadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['unloadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['unloadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['unloadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            widget.goodsList['loadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['loadTimeHms'] = startTimeCode;
                            widget.goodsList['unLoadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['unLoadTimeHms'] = endTimeCode;
                            widget.goodsList['deposit'] = depositNum;
                            widget.goodsList['depositType'] = depositType;
                            // if (payType == 1)
                            widget.goodsList['freight'] = MyBid;
                            widget.goodsList['type'] = payType - 1;
                            widget.goodsList['remark'] = remarkStr;
                            print(widget.goodsList['cargoInfo']);
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) {
                                return DesignatedDriverView(goodsMap: {
                                  "id": shipperId,
                                  "companyId":companyId,
                                  "orgId": orgId,
                                  "orderId": "0",
                                  "waybillId": "0",
                                  "category": 0,
                                  "payPeriod":payPeriod!=-1?payPeriod:int.parse(dayStr),
                                  "invoiceType": widget
                                      .goodsList['invoiceType'],
                                  "loadPlaceInfo":loadPlaceInfo,
                                  "unloadPlaceInfo": unloadPlaceInfo,
                                  "distance": widget.goodsList['distance'],
                                  "cargoInfo": [{
                                    "cargoName":widget.goodsList['cargoInfo'][0]['cargoName'],
                                    "packageType":widget.goodsList['cargoInfo'][0]['packgeType'],
                                    "cargoTypeCode":widget.goodsList['cargoInfo'][0]['cargoTypeCode'],
                                    "cargoWeight":widget.goodsList['cargoInfo'][0]['cargoWeight'],
                                    "cargoVolume":widget.goodsList['cargoInfo'][0]['cargoVolume'],
                                  }],
                                  "vehicleLength": widget
                                      .goodsList['vehicleLength'],
                                  "vehicleModel": widget
                                      .goodsList['vehicleType'],
                                  "loadDay": "${DateTime
                                      .now()
                                      .year}-$startTimeDay",
                                  "loadTime": startTimeCode.replaceAll(",", "-"),
                                  "unloadDay": "${DateTime
                                      .now()
                                      .year}-$endTimeDay",
                                  "unloadTime": endTimeCode.replaceAll(",", "-"),
                                  "deposit": depositNum,
                                  "depositType": widget
                                      .goodsList['depositType'],
                                  // "price": payType == 1 ? widget
                                  //     .goodsList['freight'] : 0,
                                  "techServiceCharge": widget
                                      .goodsList['techServiceCharge'],
                                  "elecProtocolCharge": widget
                                      .goodsList['elecProtocolCharge'],
                                  "type": widget.goodsList['type'],
                                  "remark": widget.goodsList['remark'],

                                  "status": widget.goodsList['status'],
                                  "sortCode": 0,
                                  "shipperId": shipperId,
                                  "price": payType == 1 ? MyBid : 0,
                                  "priceUnit": BidType + 1,
                                  "trajectoryVerificationCharge": 0,
                                  "insurance": !isChooseInsure ||
                                      insureMsgList.isEmpty ? null : [
                                    {"insuranceId": insuranceld,
                                      "policyholder": insureMsgList[1] !=
                                          "司机" ? 0 : 1,
                                      "insurer": insureMsgList[2] != "司机"
                                          ? 0
                                          : 1,
                                      "goodsAmount": insureMsgList[0]
                                          .replaceAll("万", "0000"),
                                      "type": 0,
                                      "insuranceRate": insureList[0]['rates'],
                                      "insuranceAmount": null,
                                      "policyholderName": insureMsgList[1] !=
                                          "司机" ? insureMsgList[1] : null,
                                      "insurerName": insureMsgList[2] !=
                                          "司机"
                                          ? insureMsgList[2]
                                          : null,
                                      "insurerCard": null,
                                    }
                                  ],

                                }, findType: 2,

                                );
                              }));
                        }
                        },
                      ),
                    BrnSmallMainButton(
                      title:  widget.editType==1||widget.editType==3?'确认发货':"确认编辑",
                      textColor: Colors.white,
                      bgColor: MyColors.themeColor,
                      radius: 30,
                      fontSize: 14.sp,
                      width:  widget.editType==1||widget.editType==3?150.w:screenSize.width-30.w,
                      onTap: () async{
                        String? shipperId=await UserIdManager.getUserID();
                        if (widget.editType==1) {
                          print(companyId);
                          // if (insureMsgList.isNotEmpty&& isChooseInsure) {
                          //   Navigator.push(context,
                          //       MaterialPageRoute(builder: (context) {
                          //         return PayInsurancePremiums(goodsMap: {
                          //           "id": shipperId,
                          //           "companyId": "0",
                          //           "orgId": "0",
                          //           "orderId": "0",
                          //           "waybillId": "0",
                          //           "category": 0,
                          //           "invoiceType": widget
                          //               .goodsList['invoiceType'],
                          //           "loadPlaceInfo": widget
                          //               .goodsList['loadPlaceInfo'],
                          //           "unloadPlaceInfo": widget
                          //               .goodsList['unloadPlaceInfo'],
                          //           "distance": widget.goodsList['distance'],
                          //           "cargoInfo": widget
                          //               .goodsList['cargoInfo'],
                          //           "vehicleLength": widget
                          //               .goodsList['vehicleLength'],
                          //           "vehicleType": widget
                          //               .goodsList['vehicleType'],
                          //           "loadTimeDay": "${DateTime
                          //               .now()
                          //               .year}-$startTimeDay",
                          //           "loadTimeHms": startTimeCode,
                          //           "unLoadTimeDay": "${DateTime
                          //               .now()
                          //               .year}-$endTimeDay",
                          //           "unLoadTimeHms": endTimeCode,
                          //           "deposit": depositNum,
                          //           "depositType": widget
                          //               .goodsList['depositType'],
                          //           "freight": payType == 1 ? widget
                          //               .goodsList['freight'] : 0,
                          //           "techServiceCharge": widget
                          //               .goodsList['techServiceCharge'],
                          //           "elecProtocolCharge": widget
                          //               .goodsList['elecProtocolCharge'],
                          //           "type": widget.goodsList['type'],
                          //           "remark": widget.goodsList['remark'],
                          //
                          //           "status": widget.goodsList['status'],
                          //           "sortCode": 0,
                          //           "shipperId": shipperId,
                          //           "price": payType == 1 ? MyBid : 0,
                          //           "priceUnit": BidType + 1,
                          //           "trajectoryVerificationCharge": 0,
                          //           "insurance": !isChooseInsure ||
                          //               insureMsgList.isEmpty ? null : [
                          //             {"insuranceId": insuranceld,
                          //               "policyholder": insureMsgList[1] !=
                          //                   "司机" ? 0 : 1,
                          //               "insurer": insureMsgList[2] != "司机"
                          //                   ? 0
                          //                   : 1,
                          //               "goodsAmount": insureMsgList[0]
                          //                   .replaceAll("万", "0000"),
                          //               "type": 0,
                          //               "insuranceRate": insureList[0]['rates'],
                          //               "insuranceAmount": null,
                          //               "policyholderName": insureMsgList[1] !=
                          //                   "司机" ? insureMsgList[1] : null,
                          //               "insurerName": insureMsgList[2] !=
                          //                   "司机"
                          //                   ? insureMsgList[2]
                          //                   : null,
                          //               "insurerCard": null,
                          //             }
                          //           ],
                          //         }, goodsType: 1,
                          //         );
                          //       }));
                          // } else {
                          print(startTimeDay);
                          if (startTimeDay == "") {
                            BrnToast.show("请选择装货时间", context);
                          } else if (isAgree == "0") {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return BrnDialog(
                                  titleText: "请阅读并同意用户协议",
                                  actionsWidget: [
                                    TextButton(
                                      onPressed: () {
                                        setState(() {
                                          isAgree="1";
                                          Navigator.pop(context);
                                          FocusScope.of(context).unfocus();

                                        });
                                      },
                                      child: Text("同意",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                    ),
                                    TextButton(
                                      onPressed: () {
                                        Navigator.pop(context);
                                        FocusScope.of(context).unfocus();
                                      },
                                      child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                    ),
                                  ],
                                );
                              },
                            );
                          } else if (payType == -1) {
                            BrnToast.show("请选择货源类型", context);
                          } else if (payType == 1 && MyBid == "") {
                            BrnToast.show("请输入运费金额", context);
                          } else {
                            if(MyBid!="")payType=1;

                            List loadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['loadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['loadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['loadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['loadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['loadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['loadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['loadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['loadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['loadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['loadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['loadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['loadPlaceInfo'].length==2){
                              loadPlaceInfo.add({
                                "province": widget.goodsList['loadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['loadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['loadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['loadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['loadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['loadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['loadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['loadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['loadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['loadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['loadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            List unloadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['unloadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['unloadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['unloadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['unloadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['unloadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['unloadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['unloadPlaceInfo'].length==2){
                              unloadPlaceInfo.add({
                                "province": widget.goodsList['unloadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['unloadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['unloadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['unloadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['unloadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['unloadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['unloadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['unloadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['unloadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['unloadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['unloadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            widget.goodsList['loadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['loadTimeHms'] = startTimeCode;
                            widget.goodsList['unLoadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['unLoadTimeHms'] = endTimeCode;
                            widget.goodsList['deposit'] = depositNum;
                            widget.goodsList['depositType'] = depositType;
                            // if (payType == 1)
                              widget.goodsList['freight'] = MyBid;
                            widget.goodsList['type'] = payType - 1;
                            widget.goodsList['remark'] = remarkStr;
                            print(widget.goodsList['cargoInfo']);
                            LoadingDialog.show(context);
                            dio.interceptors.add(InterceptorsWrapper(
                                onRequest: (options, handler) async {
                                  options.headers["satoken"] =
                                  await TokenManager.getToken();
                                  return handler.next(options);
                                }
                            ));
                            dio.post(
                              MyServiceUrl.header +
                                  'api/goods/goods/add',
                              data: {
                                "id": shipperId,
                                "companyId":companyId,
                                "orgId": orgId,
                                "orderId": "0",
                                "waybillId": "0",
                                "category": 0,
                                "payPeriod":payPeriod!=-1?payPeriod:int.parse(dayStr),
                                "invoiceType": widget
                                    .goodsList['invoiceType'],
                                "loadPlaceInfo":loadPlaceInfo,
                                "unloadPlaceInfo": unloadPlaceInfo,
                                "distance": widget.goodsList['distance'],
                                "cargoInfo": [{
                                  "cargoName":widget.goodsList['cargoInfo'][0]['cargoName'],
                                  "packageType":widget.goodsList['cargoInfo'][0]['packgeType'],
                                  "cargoTypeCode":widget.goodsList['cargoInfo'][0]['cargoTypeCode'],
                                  "cargoWeight":widget.goodsList['cargoInfo'][0]['cargoWeight'],
                                  "cargoVolume":widget.goodsList['cargoInfo'][0]['cargoVolume'],
                                }],
                                "vehicleLength": widget
                                    .goodsList['vehicleLength'],
                                "vehicleModel": widget
                                    .goodsList['vehicleType'],
                                "loadDay": "${DateTime
                                    .now()
                                    .year}-$startTimeDay",
                                "loadTime": startTimeCode.replaceAll(",", "-"),
                                "unloadDay":endTimeDay!=""? "${DateTime
                                    .now()
                                    .year}-$endTimeDay":"",
                                "unloadTime": endTimeCode.replaceAll(",", "-"),
                                "deposit": depositNum,
                                "depositType": widget
                                    .goodsList['depositType'],
                                // "price": payType == 1 ? widget
                                //     .goodsList['freight'] : 0,
                                "techServiceCharge": widget
                                    .goodsList['techServiceCharge'],
                                "elecProtocolCharge": widget
                                    .goodsList['elecProtocolCharge'],
                                "type": widget.goodsList['type'],
                                "remark": widget.goodsList['remark'],

                                "status": widget.goodsList['status'],
                                "sortCode": 0,
                                "shipperId": shipperId,
                                "price": payType == 1 ? MyBid : 0,
                                "priceUnit": BidType + 1,
                                "trajectoryVerificationCharge": 0,
                                "insurance": !isChooseInsure ||
                                    insureMsgList.isEmpty ? null : [
                                  {"insuranceId": insuranceld,
                                    "policyholder": insureMsgList[1] !=
                                        "司机" ? 0 : 1,
                                    "insurer": insureMsgList[2] != "司机"
                                        ? 0
                                        : 1,
                                    "goodsAmount": insureMsgList[0]
                                        .replaceAll("万", "0000"),
                                    "type": 0,
                                    "insuranceRate": insureList[0]['rates'],
                                    "insuranceAmount": null,
                                    "policyholderName": insureMsgList[1] !=
                                        "司机" ? insureMsgList[1] : null,
                                    "insurerName": insureMsgList[2] !=
                                        "司机"
                                        ? insureMsgList[2]
                                        : null,
                                    "insurerCard": null,
                                  }
                                ],

                              },


                              options: Options(
                                sendTimeout: Duration(seconds: 2),
                                receiveTimeout: Duration(seconds: 50),
                              ),
                              onSendProgress: (a, b) =>
                                  print('send ${a / b}'),
                              onReceiveProgress: (a, b) =>
                                  print('received ${a / b}'),
                            )
                                .then((r) {
                              setState(() {
                                print(r);
                                Map<String, dynamic> jsonMap = json.decode(
                                    r.toString());
                                // 获取code和data
                                String code = jsonMap['code'].toString();
                                if (code == "200") {

                                  print("code：$code");
                                  LoadingDialog.hide(context);
                                  BrnDialogManager.showConfirmDialog(
                                      context,
                                      title: "发布成功,是否再发一单？",
                                      cancel: "",
                                      cancelWidget: GestureDetector(
                                        child: Center(
                                          child: Text("返回",
                                            style: TextStyle(
                                                color: Colors.black,fontSize: 14.sp),),
                                        ),
                                        onTap: () {
                                          Navigator.pushReplacement(
                                            context,
                                            MaterialPageRoute(
                                              builder: (context) =>
                                                  TabbarView(pateIndex: 0,),
                                              fullscreenDialog: true,),
                                          );
                                        },
                                      ),
                                      conformWidget: GestureDetector(
                                        child: Center(
                                          child: Text("再发一单",
                                            style: TextStyle(
                                                color: MyColors
                                                    .themeColor,fontSize: 14.sp),),
                                        ),
                                        onTap: () {
                                          Navigator.pop(context);
                                        },
                                      ),
                                      confirm: "",
                                      onConfirm: () {
                                        Navigator.pop(context);
                                      },
                                      onCancel: () {


                                      });
                                } else {
                                  LoadingDialog.hide(context);
                                  BrnToast.show(jsonMap['msg'].toString(), context);
                                }
                              });
                            }).catchError((error) {
                              // BrnToast.show(error.toString(), context);
                              print(error);
                              ;
                            });
                            // LoadingDialog.show(context);
                            // dio.interceptors.add(InterceptorsWrapper(
                            //     onRequest: (options, handler) async {
                            //       options.headers["satoken"] =
                            //       await TokenManager.getToken();
                            //       return handler.next(options);
                            //     }
                            // ));
                            // dio
                            //     .post(
                            //   MyServiceUrl.header +
                            //       'api/goods/goods/goods/add',
                            //   data: {
                            //     "id": shipperId,
                            //     "companyId": "0",
                            //     "orgId": "0",
                            //     "orderId": "0",
                            //     "waybillId": "0",
                            //     "category": 0,
                            //     "invoiceType": widget
                            //         .goodsList['invoiceType'],
                            //     "loadPlaceInfo": widget
                            //         .goodsList['loadPlaceInfo'],
                            //     "unloadPlaceInfo": widget
                            //         .goodsList['unloadPlaceInfo'],
                            //     "distance": widget.goodsList['distance'],
                            //     "cargoInfo": widget.goodsList['cargoInfo'],
                            //     "vehicleLength": widget
                            //         .goodsList['vehicleLength'],
                            //     "vehicleType": widget
                            //         .goodsList['vehicleType'],
                            //     "loadTimeDay": "${DateTime
                            //         .now()
                            //         .year}-$startTimeDay",
                            //     "loadTimeHms": startTimeCode,
                            //     "unLoadTimeDay": "${DateTime
                            //         .now()
                            //         .year}-$endTimeDay",
                            //     "unLoadTimeHms": endTimeCode,
                            //     "deposit": depositNum,
                            //     "depositType": widget
                            //         .goodsList['depositType'],
                            //     "freight": payType == 1 ? widget
                            //         .goodsList['freight'] : 0,
                            //     "techServiceCharge": widget
                            //         .goodsList['techServiceCharge'],
                            //     "elecProtocolCharge": widget
                            //         .goodsList['elecProtocolCharge'],
                            //     "type": widget.goodsList['type'],
                            //     "remark": widget.goodsList['remark'],
                            //
                            //     "status": widget.goodsList['status'],
                            //     "sortCode": 0,
                            //     "shipperId": shipperId,
                            //     "price": payType == 1 ? MyBid : 0,
                            //     "priceUnit": BidType + 1,
                            //     "trajectoryVerificationCharge": 0,
                            //     "insurance": !isChooseInsure ||
                            //         insureMsgList.isEmpty ? null : [
                            //       {"insuranceId": insuranceld,
                            //         "policyholder": insureMsgList[1] !=
                            //             "司机" ? 0 : 1,
                            //         "insurer": insureMsgList[2] != "司机"
                            //             ? 0
                            //             : 1,
                            //         "goodsAmount": insureMsgList[0]
                            //             .replaceAll("万", "0000"),
                            //         "type": 0,
                            //         "insuranceRate": insureList[0]['rates'],
                            //         "insuranceAmount": null,
                            //         "policyholderName": insureMsgList[1] !=
                            //             "司机" ? insureMsgList[1] : null,
                            //         "insurerName": insureMsgList[2] !=
                            //             "司机"
                            //             ? insureMsgList[2]
                            //             : null,
                            //         "insurerCard": null,
                            //       }
                            //     ],
                            //   },
                            //   options: Options(
                            //     sendTimeout: Duration(seconds: 2),
                            //     receiveTimeout: Duration(seconds: 50),
                            //   ),
                            //   onSendProgress: (a, b) =>
                            //       print('send ${a / b}'),
                            //   onReceiveProgress: (a, b) =>
                            //       print('received ${a / b}'),
                            // )
                            //     .then((r) {
                            //   setState(() {
                            //     print(r);
                            //     Map<String, dynamic> jsonMap = json.decode(
                            //         r.toString());
                            //     // 获取code和data
                            //     String code = jsonMap['code'].toString();
                            //     if (code == "200") {
                            //       print("code：$code");
                            //       LoadingDialog.hide(context);
                            //       BrnDialogManager.showConfirmDialog(
                            //           context,
                            //           title: "发布成功,是否再发一单？",
                            //           cancel: "",
                            //           cancelWidget: GestureDetector(
                            //             child: Center(
                            //               child: Text("返回",
                            //                 style: TextStyle(
                            //                     color: Colors.black,fontSize: 14.sp),),
                            //             ),
                            //             onTap: () {
                            //               Navigator.pushReplacement(
                            //                 context,
                            //                 MaterialPageRoute(
                            //                   builder: (context) =>
                            //                       TabbarView(pateIndex: 0,),
                            //                   fullscreenDialog: true,),
                            //               );
                            //             },
                            //           ),
                            //           conformWidget: GestureDetector(
                            //             child: Center(
                            //               child: Text("再发一单",
                            //                 style: TextStyle(
                            //                     color: MyColors
                            //                         .themeColor,fontSize: 14.sp),),
                            //             ),
                            //             onTap: () {
                            //               Navigator.pop(context);
                            //             },
                            //           ),
                            //           confirm: "",
                            //           onConfirm: () {
                            //             Navigator.pop(context);
                            //           },
                            //           onCancel: () {
                            //
                            //
                            //           });
                            //     } else {
                            //       LoadingDialog.hide(context);
                            //       BrnToast.show(jsonMap['msg'], context);
                            //     }
                            //   });
                            // }).catchError((error) {
                            //   print(error);
                            //   ;
                            // });
                          }
                          // }

                        }else if(widget.editType==2) {

                          if (startTimeDay == "") {
                            BrnToast.show("请选择装货时间", context);
                          } else if (isAgree == "0") {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return BrnDialog(
                                  titleText: "请阅读并同意用户协议",
                                  actionsWidget: [
                                    TextButton(
                                      onPressed: () {
                                        setState(() {
                                          isAgree="1";
                                          Navigator.pop(context);
                                          FocusScope.of(context).unfocus();

                                        });
                                      },
                                      child: Text("同意",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                    ),
                                    TextButton(
                                      onPressed: () {
                                        Navigator.pop(context);
                                        FocusScope.of(context).unfocus();
                                      },
                                      child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                    ),
                                  ],
                                );
                              },
                            );
                          } else if (payType == -1) {
                            BrnToast.show("请选择货源类型", context);
                          } else if (payType == 1 && MyBid == "") {
                            BrnToast.show("请输入运费金额", context);
                          } else {

                            if(MyBid!="")payType=1;
                            List loadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['loadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['loadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['loadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['loadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['loadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['loadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['loadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['loadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['loadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['loadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['loadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['loadPlaceInfo'].length==2){
                              loadPlaceInfo.add({
                                "province": widget.goodsList['loadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['loadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['loadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['loadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['loadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['loadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['loadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['loadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['loadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['loadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['loadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            List unloadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['unloadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['unloadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['unloadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['unloadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['unloadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['unloadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['unloadPlaceInfo'].length==2){
                              unloadPlaceInfo.add({
                                "province": widget.goodsList['unloadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['unloadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['unloadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['unloadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['unloadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['unloadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['unloadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['unloadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['unloadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['unloadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['unloadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            widget.goodsList['loadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['loadTimeHms'] = startTimeCode;
                            widget.goodsList['unLoadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$endTimeDay";
                            widget.goodsList['unLoadTimeHms'] = endTimeCode;
                            widget.goodsList['deposit'] = depositNum;
                            widget.goodsList['depositType'] = depositType;
                            // if (payType == 1)
                              widget.goodsList['freight'] = MyBid;
                            widget.goodsList['type'] = payType - 1;
                            widget.goodsList['remark'] = remarkStr;
                            //       if(isChooseInsure&&insureMsgList[1]!="司机"&&editInsureType==1){
                            //         Navigator.push(context,
                            //             MaterialPageRoute(builder: (context) {
                            //               return PayInsurancePremiums(goodsMap: {
                            //                 "id": widget.dataMap['id'],
                            //                 "status":0,
                            //                 "companyId": "0",
                            //                 "orgId": "0",
                            //                 "orderId": "0",
                            //                 "waybillId": "0",
                            //                 "category": 0,
                            //                 "invoiceType": 0,
                            //                 "loadPlaceInfo": widget.dataMap['loadPlaceInfo'],
                            //                 "unloadPlaceInfo": widget.dataMap['unloadPlaceInfo'],
                            //                 "distance": widget.goodsList['distance'],
                            //                 "cargoInfo": widget.dataMap['cargoInfo'],
                            //                 "vehicleLength": widget.dataMap['vehicleLength'],
                            //                 "vehicleType": widget.dataMap['vehicleType'],
                            //                 "loadTimeDay": widget.dataMap['loadTimeDay'],
                            //                 "loadTimeHms":  widget.dataMap['loadTimeHms'],
                            //                 "unLoadTimeDay": widget.dataMap['unLoadTimeDay'],
                            //                 "unLoadTimeHms": widget.dataMap['unLoadTimeHms'],
                            //                 "deposit": depositNum,
                            //                 "depositType":widget.dataMap['depositType'],
                            //                 "freight": payType==1?MyBid:0,
                            //                 "techServiceCharge": 0,
                            //                 "elecProtocolCharge": 0,
                            //                 "type":widget.dataMap['type'],
                            //                 "remark": widget.dataMap['remark'],
                            //                 "insurance":!isChooseInsure||insureMsgList.isEmpty? null:[
                            //                   {"insuranceId":insuranceld,
                            //                     "policyholder": insureMsgList[1]!="司机"?0:1,
                            //                     "insurer": insureMsgList[2]!="司机"?0:1,
                            //                     "goodsAmount":insureMsgList[0].replaceAll("万", "0000"),
                            //                     "type":0,
                            //                     "insuranceRate":insureList[0]['rates'],
                            //                     "insuranceAmount":null,
                            //                     "policyholderName":insureMsgList[1]!="司机"?insureMsgList[1]:null,
                            //                     "insurerName":insureMsgList[2]!="司机"?insureMsgList[2]:null,
                            //                     "insurerCard":null,
                            //                     "status":editInsureType,
                            //                   }
                            //                 ],
                            //                 "sortCode": 0,
                            //                 "shipperId": widget.dataMap['shipperId'],
                            //                 "price": payType==1?MyBid:0,
                            //                 "priceUnit": BidType+1,
                            //                 "trajectoryVerificationCharge":0
                            //               }, goodsType: 2,
                            //             );
                            //         }));
                            //
                            // }else {
                            LoadingDialog.show(context);
                            dio.interceptors.add(InterceptorsWrapper(
                                onRequest: (options, handler) async {
                                  options.headers["satoken"] =  await TokenManager.getToken();;
                                  return handler.next(options);
                                }
                            ));
                            dio
                                .post(
                              MyServiceUrl.header+'api/goods/goods/edit',
                              data: {
                                "id": widget.dataMap['id'],
                                "companyId": companyId,
                                "orgId":orgId,
                                "orderId": "0",
                                "waybillId": "0",
                                "category": 0,
                                "payPeriod":payPeriod!=-1?payPeriod:int.parse(dayStr),
                                "invoiceType": widget
                                    .goodsList['invoiceType'],
                                "loadPlaceInfo":loadPlaceInfo,
                                "unloadPlaceInfo": unloadPlaceInfo,
                                "distance": widget.goodsList['distance'],
                                "cargoInfo": [{
                                  "cargoName":widget.goodsList['cargoInfo'][0]['cargoName'],
                                  "packageType":widget.goodsList['cargoInfo'][0]['packgeType'],
                                  "cargoTypeCode":widget.goodsList['cargoInfo'][0]['cargoTypeCode'],
                                  "cargoWeight":widget.goodsList['cargoInfo'][0]['cargoWeight'],
                                  "cargoVolume":widget.goodsList['cargoInfo'][0]['cargoVolume'],
                                }],
                                "vehicleLength": widget
                                    .goodsList['vehicleLength'],
                                "vehicleModel": widget
                                    .goodsList['vehicleType'],
                                "loadDay": "${DateTime
                                    .now()
                                    .year}-$startTimeDay",
                                "loadTime": startTimeCode.replaceAll(",", "-"),
                                "unloadDay":endTimeDay!=""? "${DateTime
                                    .now()
                                    .year}-$endTimeDay":"",
                                "unloadTime": endTimeCode.replaceAll(",", "-"),
                                "deposit": depositNum,
                                "depositType": widget
                                    .goodsList['depositType'],
                                "price": MyBid,
                                "freight":MyBid,
                                "techServiceCharge": widget
                                    .goodsList['techServiceCharge'],
                                "elecProtocolCharge": widget
                                    .goodsList['elecProtocolCharge'],
                                "type": widget.goodsList['type'],
                                "remark": widget.goodsList['remark'],

                                "status": widget.goodsList['status'],
                                "sortCode": 0,
                                "shipperId": shipperId,
                                "priceUnit": BidType + 1,
                                "trajectoryVerificationCharge": 0,
                                "insurance": !isChooseInsure ||
                                    insureMsgList.isEmpty ? null : [
                                  {"insuranceId": insuranceld,
                                    "policyholder": insureMsgList[1] !=
                                        "司机" ? 0 : 1,
                                    "insurer": insureMsgList[2] != "司机"
                                        ? 0
                                        : 1,
                                    "goodsAmount": insureMsgList[0]
                                        .replaceAll("万", "0000"),
                                    "type": 0,
                                    "insuranceRate": insureList[0]['rates'],
                                    "insuranceAmount": null,
                                    "policyholderName": insureMsgList[1] !=
                                        "司机" ? insureMsgList[1] : null,
                                    "insurerName": insureMsgList[2] !=
                                        "司机"
                                        ? insureMsgList[2]
                                        : null,
                                    "insurerCard": null,     }
                                ],
                              },
                              options: Options(
                                sendTimeout: Duration(seconds: 2),
                                receiveTimeout: Duration(seconds: 50),
                              ),
                              onSendProgress: (a, b) =>
                                  print('send ${a / b}'),
                              onReceiveProgress: (a, b) =>
                                  print('received ${a / b}'),
                            )
                                .then((r) {
                              setState(() {
                                print(r);
                                Map<String, dynamic> jsonMap = json.decode(
                                    r.toString());
                                // 获取code和data
                                String code = jsonMap['code'].toString();
                                if (code == "200") {
                                  print("code：$code");
                                  LoadingDialog.hide(context);
                                  BrnToast.show("修改成功", context);
                                  // Navigator.pushReplacement(
                                  //   context,
                                  //   MaterialPageRoute(builder: (context) => TabbarView(pateIndex: 0,),fullscreenDialog: true,),
                                  // );
                                  Navigator.pop(context);
                                  Navigator.pop(context,"success");
                                }else{
                                  LoadingDialog.hide(context);
                                  BrnToast.show(jsonMap['msg'], context);
                                }
                              });
                            }).catchError((error) {
                              LoadingDialog.hide(context);
                              print(error);
                              BrnToast.show(error.toString(), context);
                              ;
                            });
                            // }
                          }
                        }else if(widget.editType==3) {

                          if (startTimeDay == "") {
                            BrnToast.show("请选择装货时间", context);
                          } else if (isAgree == "0") {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return BrnDialog(
                                  titleText: "请阅读并同意用户协议",
                                  actionsWidget: [
                                    TextButton(
                                      onPressed: () {
                                        setState(() {
                                          isAgree="1";
                                          Navigator.pop(context);
                                          FocusScope.of(context).unfocus();

                                        });
                                      },
                                      child: Text("同意",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                    ),
                                    TextButton(
                                      onPressed: () {
                                        Navigator.pop(context);
                                        FocusScope.of(context).unfocus();
                                      },
                                      child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                    ),
                                  ],
                                );
                              },
                            );
                          } else if (payType == -1) {
                            BrnToast.show("请选择货源类型", context);
                          } else if (payType == 1 && MyBid == "") {
                            BrnToast.show("请输入运费金额", context);
                          } else {
                            if(MyBid!="")payType=1;
                            List loadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['loadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['loadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['loadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['loadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['loadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['loadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['loadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['loadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['loadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['loadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['loadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['loadPlaceInfo'].length==2){
                              loadPlaceInfo.add({
                                "province": widget.goodsList['loadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['loadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['loadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['loadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['loadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['loadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['loadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['loadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['loadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['loadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['loadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            List unloadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['unloadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['unloadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['unloadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['unloadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['unloadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['unloadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['unloadPlaceInfo'].length==2){
                              unloadPlaceInfo.add({
                                "province": widget.goodsList['unloadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['unloadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['unloadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['unloadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['unloadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['unloadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['unloadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['unloadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['unloadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['unloadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['unloadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            widget.goodsList['loadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['loadTimeHms'] = startTimeCode;
                            widget.goodsList['unLoadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['unLoadTimeHms'] = endTimeCode;
                            widget.goodsList['deposit'] = depositNum;
                            widget.goodsList['depositType'] = depositType;
                            // if (payType == 1)
                              widget.goodsList['freight'] = MyBid;
                            widget.goodsList['type'] = payType - 1;
                            widget.goodsList['remark'] = remarkStr;
                            print(widget.goodsList['cargoInfo']);
                            LoadingDialog.show(context);
                            dio.interceptors.add(InterceptorsWrapper(
                                onRequest: (options, handler) async {
                                  options.headers["satoken"] =
                                  await TokenManager.getToken();
                                  return handler.next(options);
                                }
                            ));
                            dio.post(
                              MyServiceUrl.header +
                                  'api/goods/goods/add',
                              data: {
                                "id": shipperId,
                                "companyId": companyId,
                                "orgId": orgId,
                                "orderId": "0",
                                "waybillId": "0",
                                "category": 0,
                                "payPeriod":payPeriod!=-1?payPeriod:int.parse(dayStr),
                                "invoiceType": widget
                                    .goodsList['invoiceType'],
                                "loadPlaceInfo":loadPlaceInfo,
                                "unloadPlaceInfo": unloadPlaceInfo,
                                "distance": widget.goodsList['distance'],
                                "cargoInfo": [{
                                  "cargoName":widget.goodsList['cargoInfo'][0]['cargoName'],
                                  "packageType":widget.goodsList['cargoInfo'][0]['packgeType'],
                                  "cargoTypeCode":widget.goodsList['cargoInfo'][0]['cargoTypeCode'],
                                  "cargoWeight":widget.goodsList['cargoInfo'][0]['cargoWeight'],
                                  "cargoVolume":widget.goodsList['cargoInfo'][0]['cargoVolume'],
                                }],
                                "vehicleLength": widget
                                    .goodsList['vehicleLength'],
                                "vehicleModel": widget
                                    .goodsList['vehicleType'],
                                "loadDay": "${DateTime
                                    .now()
                                    .year}-$startTimeDay",
                                "loadTime": startTimeCode.replaceAll(",", "-"),
                                "unloadDay":endTimeDay!=""? "${DateTime
                                    .now()
                                    .year}-$endTimeDay":"",
                                "unloadTime": endTimeCode.replaceAll(",", "-"),
                                "deposit": depositNum,
                                "depositType": widget
                                    .goodsList['depositType'],
                                "price": widget
                                    .goodsList['freight'],
                                "techServiceCharge": widget
                                    .goodsList['techServiceCharge'],
                                "elecProtocolCharge": widget
                                    .goodsList['elecProtocolCharge'],
                                "type": widget.goodsList['type'],
                                "remark": widget.goodsList['remark'],

                                "status": widget.goodsList['status'],
                                "sortCode": 0,
                                "shipperId": shipperId,
                                // "price": payType == 1 ? MyBid : 0,
                                "priceUnit": BidType + 1,
                                "trajectoryVerificationCharge": 0,
                                "insurance": !isChooseInsure ||
                                    insureMsgList.isEmpty ? null : [
                                  {"insuranceId": insuranceld,
                                    "policyholder": insureMsgList[1] !=
                                        "司机" ? 0 : 1,
                                    "insurer": insureMsgList[2] != "司机"
                                        ? 0
                                        : 1,
                                    "goodsAmount": insureMsgList[0]
                                        .replaceAll("万", "0000"),
                                    "type": 0,
                                    "insuranceRate": insureList[0]['rates'],
                                    "insuranceAmount": null,
                                    "policyholderName": insureMsgList[1] !=
                                        "司机" ? insureMsgList[1] : null,
                                    "insurerName": insureMsgList[2] !=
                                        "司机"
                                        ? insureMsgList[2]
                                        : null,
                                    "insurerCard": null,
                                  }
                                ],

                              },


                              options: Options(
                                sendTimeout: Duration(seconds: 2),
                                receiveTimeout: Duration(seconds: 50),
                              ),
                              onSendProgress: (a, b) =>
                                  print('send ${a / b}'),
                              onReceiveProgress: (a, b) =>
                                  print('received ${a / b}'),
                            )
                                .then((r) {
                              setState(() {
                                print(r);
                                Map<String, dynamic> jsonMap = json.decode(
                                    r.toString());
                                // 获取code和data
                                String code = jsonMap['code'].toString();
                                if (code == "200") {

                                  print("code：$code");
                                  LoadingDialog.hide(context);
                                  BrnDialogManager.showConfirmDialog(
                                      context,
                                      title: "发布成功,是否再发一单？",
                                      cancel: "",
                                      cancelWidget: GestureDetector(
                                        child: Center(
                                          child: Text("返回",
                                            style: TextStyle(
                                                color: Colors.black,fontSize: 14.sp),),
                                        ),
                                        onTap: () {
                                          Navigator.pushReplacement(
                                            context,
                                            MaterialPageRoute(
                                              builder: (context) =>
                                                  TabbarView(pateIndex: 0,),
                                              fullscreenDialog: true,),
                                          );
                                        },
                                      ),
                                      conformWidget: GestureDetector(
                                        child: Center(
                                          child: Text("再发一单",
                                            style: TextStyle(
                                                color: MyColors
                                                    .themeColor,fontSize: 14.sp),),
                                        ),
                                        onTap: () {
                                          Navigator.pop(context);
                                        },
                                      ),
                                      confirm: "",
                                      onConfirm: () {
                                        Navigator.pop(context);
                                      },
                                      onCancel: () {


                                      });
                                } else {
                                  LoadingDialog.hide(context);
                                  BrnToast.show(jsonMap['msg'].toString(), context);
                                }
                              });
                            }).catchError((error) {
                              // BrnToast.show(error.toString(), context);
                              print(error);
                              ;
                            });
                            // if (insureMsgList.isNotEmpty&&insureMsgList[1] != "司机" &&
                            //     isChooseInsure) {
                            //   Navigator.push(context,
                            //       MaterialPageRoute(builder: (context) {
                            //         return PayInsurancePremiums(goodsMap: {
                            //           "id": widget.dataMap['id'],
                            //           "companyId": "0",
                            //           "orgId": "0",
                            //           "orderId": "0",
                            //           "waybillId": "0",
                            //           "category": 0,
                            //           "invoiceType": 0,
                            //           "loadPlaceInfo": widget
                            //               .dataMap['loadPlaceInfo'],
                            //           "unloadPlaceInfo": widget
                            //               .dataMap['unloadPlaceInfo'],
                            //           "distance": widget
                            //               .goodsList['distance'],
                            //           "cargoInfo": widget
                            //               .dataMap['cargoInfo'],
                            //           "vehicleLength": widget
                            //               .dataMap['vehicleLength'],
                            //           "vehicleType": widget
                            //               .dataMap['vehicleType'],
                            //           "loadTimeDay": widget
                            //               .dataMap['loadTimeDay'],
                            //           "loadTimeHms": widget
                            //               .dataMap['loadTimeHms'],
                            //           "unLoadTimeDay": widget
                            //               .dataMap['unLoadTimeDay'],
                            //           "unLoadTimeHms": widget
                            //               .dataMap['unLoadTimeHms'],
                            //           "deposit": depositNum,
                            //           "depositType": widget
                            //               .dataMap['depositType'],
                            //           "freight": payType == 1 ? MyBid : 0,
                            //           "techServiceCharge": 0,
                            //           "elecProtocolCharge": 0,
                            //           "type": widget.dataMap['type'],
                            //           "remark": widget.dataMap['remark'],
                            //           "insurance": !isChooseInsure ||
                            //               insureMsgList.isEmpty ? null : [
                            //             {"insuranceId": insuranceld,
                            //               "policyholder": insureMsgList[1] !=
                            //                   "司机" ? 0 : 1,
                            //               "insurer": insureMsgList[2] !=
                            //                   "司机"
                            //                   ? 0
                            //                   : 1,
                            //               "goodsAmount": insureMsgList[0]
                            //                   .replaceAll("万", "0000"),
                            //               "type": 0,
                            //               "insuranceRate": insureList[0]['rates'],
                            //               "insuranceAmount": null,
                            //               "policyholderName": insureMsgList[1] !=
                            //                   "司机"
                            //                   ? insureMsgList[1]
                            //                   : null,
                            //               "insurerName": insureMsgList[2] !=
                            //                   "司机"
                            //                   ? insureMsgList[2]
                            //                   : null,
                            //               "insurerCard": null,
                            //             }
                            //           ],
                            //           "status": 0,
                            //           "sortCode": 0,
                            //           "shipperId": widget
                            //               .dataMap['shipperId'],
                            //           "price": payType == 1 ? MyBid : 0,
                            //           "priceUnit": BidType + 1,
                            //           "trajectoryVerificationCharge": 0
                            //         }, goodsType: 1,
                            //         );
                            //       }));
                            //
                            // } else {

                          }

                          // }
                        }else if(widget.editType==4) {
                          if (startTimeDay == "") {
                            BrnToast.show("请选择装货时间", context);
                          } else if (isAgree == "0") {
                            showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return BrnDialog(
                                  titleText: "请阅读并同意用户协议",
                                  actionsWidget: [
                                    TextButton(
                                      onPressed: () {
                                        setState(() {
                                          isAgree="1";
                                          Navigator.pop(context);
                                          FocusScope.of(context).unfocus();

                                        });
                                      },
                                      child: Text("同意",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                    ),
                                    TextButton(
                                      onPressed: () {
                                        Navigator.pop(context);
                                        FocusScope.of(context).unfocus();
                                      },
                                      child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                    ),
                                  ],
                                );
                              },
                            );
                          } else if (payType == -1) {
                            BrnToast.show("请选择货源类型", context);
                          } else if (payType == 1 && MyBid == "") {
                            BrnToast.show("请输入运费金额", context);
                          } else {
                            if(MyBid!="")payType=1;
                            List loadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['loadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['loadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['loadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['loadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['loadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['loadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['loadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['loadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['loadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['loadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['loadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['loadPlaceInfo'].length==2){
                              loadPlaceInfo.add({
                                "province": widget.goodsList['loadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['loadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['loadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['loadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['loadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['loadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['loadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['loadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['loadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['loadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['loadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            List unloadPlaceInfo=[
                              {
                                "province": widget
                                    .goodsList['unloadPlaceInfo'][0]['province'],
                                "city": widget
                                    .goodsList['unloadPlaceInfo'][0]['city'],
                                "county": widget
                                    .goodsList['unloadPlaceInfo'][0]['county'],
                                "address": widget
                                    .goodsList['unloadPlaceInfo'][0]['detailedAddress'],
                                "provinceCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['provinceCode'],
                                "cityCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['cityCode'],
                                "areaCode": widget
                                    .goodsList['unloadPlaceInfo'][0]['countyCode'],
                                "longitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['longitude'],
                                "latitude": widget
                                    .goodsList['unloadPlaceInfo'][0]['latitude'],
                                "contact": widget
                                    .goodsList['unloadPlaceInfo'][0]['contact'],
                                "phone": widget
                                    .goodsList['unloadPlaceInfo'][0]['contactPhone']
                              }];
                            if(widget.goodsList['unloadPlaceInfo'].length==2){
                              unloadPlaceInfo.add({
                                "province": widget.goodsList['unloadPlaceInfo'][1]['province'],
                                "city": widget.goodsList['unloadPlaceInfo'][1]['city'],
                                "county": widget.goodsList['unloadPlaceInfo'][1]['county'],
                                "address": widget.goodsList['unloadPlaceInfo'][1]['detailedAddress'],
                                "provinceCode": widget.goodsList['unloadPlaceInfo'][1]['provinceCode'],
                                "cityCode": widget.goodsList['unloadPlaceInfo'][1]['cityCode'],
                                "areaCode": widget.goodsList['unloadPlaceInfo'][1]['countyCode'],
                                "longitude": widget.goodsList['unloadPlaceInfo'][1]['longitude'],
                                "latitude": widget.goodsList['unloadPlaceInfo'][1]['latitude'],
                                "contact": widget.goodsList['unloadPlaceInfo'][1]['contact'],
                                "phone": widget.goodsList['unloadPlaceInfo'][1]['contactPhone']
                              }
                              );
                            }
                            widget.goodsList['loadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['loadTimeHms'] = startTimeCode;
                            widget.goodsList['unLoadTimeDay'] =
                            "${DateTime
                                .now()
                                .year}-$startTimeDay";
                            widget.goodsList['unLoadTimeHms'] = endTimeCode;
                            widget.goodsList['deposit'] = depositNum;
                            widget.goodsList['depositType'] = depositType;
                            // if (payType == 1)
                              widget.goodsList['freight'] = MyBid;
                            widget.goodsList['type'] = payType - 1;
                            widget.goodsList['remark'] = remarkStr;
                            LoadingDialog.show(context);
                            dio.interceptors.add(InterceptorsWrapper(
                                onRequest: (options, handler) async {
                                  options.headers["satoken"] =  await TokenManager.getToken();;
                                  return handler.next(options);
                                }
                            ));
                            dio
                                .post(
                              MyServiceUrl.header+'api/goods/goods/common/edit',
                              data: {
                                "id": widget.dataMap['id'],
                                "companyId": companyId,
                                "orgId": orgId,
                                "orderId": "0",
                                "waybillId": "0",
                                "category": 0,
                                "payPeriod":payPeriod!=-1?payPeriod:int.parse(dayStr),
                                "invoiceType": widget
                                    .goodsList['invoiceType'],
                                "loadPlaceInfo":loadPlaceInfo,
                                "unloadPlaceInfo": unloadPlaceInfo,
                                "distance": widget.goodsList['distance'],
                                "cargoInfo": [{
                                  "cargoName":widget.goodsList['cargoInfo'][0]['cargoName'],
                                  "packageType":widget.goodsList['cargoInfo'][0]['packgeType'],
                                  "cargoTypeCode":widget.goodsList['cargoInfo'][0]['cargoTypeCode'],
                                  "cargoWeight":widget.goodsList['cargoInfo'][0]['cargoWeight'],
                                  "cargoVolume":widget.goodsList['cargoInfo'][0]['cargoVolume'],
                                }],
                                "vehicleLength": widget
                                    .goodsList['vehicleLength'],
                                "vehicleModel": widget
                                    .goodsList['vehicleType'],
                                "loadDay": "${DateTime
                                    .now()
                                    .year}-$startTimeDay",
                                "loadTime": startTimeCode.replaceAll(",", "-"),
                                "unloadDay":endTimeDay!=""? "${DateTime
                                    .now()
                                    .year}-$endTimeDay":"",
                                "unloadTime": endTimeCode.replaceAll(",", "-"),
                                "deposit": depositNum,
                                "depositType": widget
                                    .goodsList['depositType'],
                                // "price": widget
                                //     .goodsList['freight'],
                                "techServiceCharge": widget
                                    .goodsList['techServiceCharge'],
                                "elecProtocolCharge": widget
                                    .goodsList['elecProtocolCharge'],
                                "type": widget.goodsList['type'],
                                "remark": widget.goodsList['remark'],

                                "status": widget.goodsList['status'],
                                "sortCode": 0,
                                "shipperId": shipperId,
                                "price":  MyBid,
                                "freight":MyBid,
                                "priceUnit": BidType + 1,
                                "trajectoryVerificationCharge": 0,
                                "insurance": !isChooseInsure ||
                                    insureMsgList.isEmpty ? null : [
                                  {"insuranceId": insuranceld,
                                    "policyholder": insureMsgList[1] !=
                                        "司机" ? 0 : 1,
                                    "insurer": insureMsgList[2] != "司机"
                                        ? 0
                                        : 1,
                                    "goodsAmount": insureMsgList[0]
                                        .replaceAll("万", "0000"),
                                    "type": 0,
                                    "insuranceRate": insureList[0]['rates'],
                                    "insuranceAmount": null,
                                    "policyholderName": insureMsgList[1] !=
                                        "司机" ? insureMsgList[1] : null,
                                    "insurerName": insureMsgList[2] !=
                                        "司机"
                                        ? insureMsgList[2]
                                        : null,
                                    "insurerCard": null,     }
                                ],
                              },
                              options: Options(
                                sendTimeout: Duration(seconds: 2),
                                receiveTimeout: Duration(seconds: 50),
                              ),
                              onSendProgress: (a, b) =>
                                  print('send ${a / b}'),
                              onReceiveProgress: (a, b) =>
                                  print('received ${a / b}'),
                            )
                                .then((r) {
                              setState(() {
                                print(r);
                                Map<String, dynamic> jsonMap = json.decode(
                                    r.toString());
                                // 获取code和data
                                String code = jsonMap['code'].toString();
                                if (code == "200") {
                                  print("code：$code");
                                  LoadingDialog.hide(context);
                                  BrnToast.show("修改成功", context);
                                  // Navigator.pushReplacement(
                                  //   context,
                                  //   MaterialPageRoute(builder: (context) => TabbarView(pateIndex: 0,),fullscreenDialog: true,),
                                  // );
                                  Navigator.pop(context);
                                  Navigator.pop(context,"success");
                                }else{
                                  LoadingDialog.hide(context);
                                  BrnToast.show(jsonMap['msg'], context);
                                }
                              });
                            }).catchError((error) {
                              LoadingDialog.hide(context);
                              print(error);
                              BrnToast.show(error.toString(), context);
                              ;
                            });
                          }
                        }

                      },
                    )
                  ],
                ),
              ],
            ),
          ),
        ],
      ),),



    );
  }

}

class ChooseTimeSheet extends StatefulWidget {
  const ChooseTimeSheet({super.key, required this.chooseTimeType, required this.timeDay, required this.timeHour, required this.timeCode});
final int chooseTimeType;
final String timeDay;
final String timeHour;
  final String timeCode;
  @override
  State<ChooseTimeSheet> createState() => _ChooseTimeSheetState();
}

class _ChooseTimeSheetState extends State<ChooseTimeSheet> {
  String startTimeDay="";
  String startTimeHour="";
  String startTimeCode="";
  List chooseTimeList=["全天都可以","凌晨 00:00-6:00","上午 06:00-12:00","下午 12:00-18:00","晚上 18:00-24:00"
    ,"00:00-02:00","02:00-:04:00","04:00-06:00","06:00-08:00","08:00-10:00","10:00-12:00","12:00-14:00",
  "14:00-16:00","16:00-18:00","18:00-20:00","20:00-22:00","22:00-24:00"];
  List timeCodeList=["0,24","0,6","6,12","12,18","18,24","0,2","2,4","4,6","6,8","8,10","10,12","12,14","14,16","16,18","18,20","20,22","22,24"];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    if(widget.timeDay.isNotEmpty){
      startTimeDay=widget.timeDay;
      startTimeHour=widget.timeHour;
    }
  }
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    var messages = AppLocalizations.of(context)!;
    List<String> dateList = generateDateList();
    return Container(
      height:320.h,
      padding: EdgeInsets.only(top: 10.h,bottom: 44.h,left: 15.w,right: 15.w),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10))),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              TextButton(onPressed: (){ Navigator.pop(context);}, child: Text("取消       ",style: TextStyle(color: Colors.black,fontSize: 14.sp),),),

              Text(widget.chooseTimeType==1? "装货时间":"卸货时间",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
              TextButton(onPressed: (){  if(startTimeHour!=""&&startTimeDay!="")
                Navigator.pop(context, [startTimeDay,startTimeHour,startTimeCode]);
              else
                BrnToast.show('请选择时间', context);}, child: Text("        确认",style: TextStyle(color:MyColors.themeColor,fontSize: 14.sp),),),

            ],
          ),
          SizedBox(height: 10.h,),
          Row(
            children: [
              Container(
                color: MyColors.backgreyColor,
                width: screenSize.width/3,
                height: 200.h,
                child:ListView.builder(
                  itemCount: dateList.length,
                  itemBuilder: (context, index) {
                    return Container(
                      padding: EdgeInsets.only(left: 8.w,top: 8.h,bottom: 8.h),
                      color: startTimeDay==dateList[index]?Colors.white:MyColors.backgreyColor,
                      child:
                      GestureDetector(
                        child:Text(
                          index==0?"今天"
                              :index==1?"明天"+"("+dateList[index]+")"
                              :index==2?"后天"+"("+dateList[index]+")"
                              :dateList[index]
                          ,style: TextStyle(color: startTimeDay==dateList[index]?MyColors.themeColor:Colors.black,fontSize: 14.sp),),
                        onTap: (){
                          setState(() {
                            startTimeDay=dateList[index];

                          });
                        },
                      ),

                    );
                  },
                ),
              ),
              Container(
                color: Colors.white,
                width: screenSize.width/2,
                height: 200.h,
                child:ListView.builder(
                  itemCount: chooseTimeList.length,
                  itemBuilder: (context, index) {
                    return Container(
                      padding: EdgeInsets.only(left: 8.w,top: 8.h,bottom: 8.h),
                      child:
                      GestureDetector(
                        child:Text(
                          chooseTimeList[index]
                          ,style: TextStyle(color: startTimeHour==chooseTimeList[index]?MyColors.themeColor:Colors.black,fontSize: 14.sp),),
                        onTap: (){
                          setState(() {
                            startTimeHour=chooseTimeList[index];
                            startTimeCode=timeCodeList[index];
                          });
                        },
                      ),

                    );
                  },
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
  List<String> generateDateList() {
    List<String> dateList = [];
    DateTime today = DateTime.now();
    dateList.add(formatDate(today));

    for (int i = 1; i <= 5; i++) {
      DateTime nextDay = today.add(Duration(days: i));
      dateList.add(formatDate(nextDay));
    }

    return dateList;
  }

  String formatDate(DateTime date) {
    // 使用intl包中的DateFormat进行日期格式化
    return DateFormat('MM-dd').format(date);
  }
}


class RemarkMessageSheet extends StatefulWidget {
  const RemarkMessageSheet({super.key, required this.remarkStr});
  final String remarkStr;
  @override
  State<RemarkMessageSheet> createState() => _RemarkMessageSheetState();
}

class _RemarkMessageSheetState extends State<RemarkMessageSheet> {
  String remarkStr="";
  String writeText="";
  List chooseList=[];
  List historyList=["请在装卸货地打开APP点击已装货和已卸货"];
  List aboutGoodsList=["装货地有禁区","卸货地有禁区","三不超","到付","全部现金"];
  List aboutCarList=["需雨布"];
@override
  void initState() {
    // TODO: implement initState
    super.initState();
    remarkStr=widget.remarkStr;
    if(remarkStr!=""&&remarkStr.contains(',')){
      chooseList=remarkStr.split(', ');
    }
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      height:470.h,
      padding: EdgeInsets.only(top: 10.h,bottom: 44.h,left: 15.w,right: 15.w),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10))),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              TextButton(onPressed: (){
                  Navigator.pop(context, widget.remarkStr);
              }, child: Text("取消",style: TextStyle(color: Colors.black,fontSize: 14.sp),)),

              Text("服务要求和备注",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
             TextButton(onPressed: (){
               if(remarkStr!="")
                 Navigator.pop(context, remarkStr);
               else
                 BrnToast.show('请填写备注信息', context);
             }, child: Text("确定",style: TextStyle(color:MyColors.themeColor,fontSize: 14.sp),)),

            ],
          ),
          SizedBox(height: 10.h,),
          Divider(height: 1.h,color: MyColors.backgreyColor,),
          SizedBox(height: 10.h,),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w),
            child: BrnInputText(
              maxHeight: 100.h,
              minHeight: 80.h,
              minLines: 1,
              maxLength: 50,
              autoFocus: false,
              bgColor: MyColors.backgreyColor,
              textString: remarkStr,
              textInputAction: TextInputAction.newline,
              maxHintLines: 20,
              hint: '请输入备注，最多50个字',
              padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
              onTextChange: (text) {
                print(text);
                // remarkStr = text;
                setState(() {
                  remarkStr = text;
                  // remarkStr=remarkStr+text;
                });
              },
              onSubmit: (text) {
                print(text);
              },
            ),
          ),
          SizedBox(height: 8.h,),
          Text("快捷输入",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
          SizedBox(height: 8.h,),
          Container(
            child:Wrap(
              spacing: 10.w, // 两个Container之间的水平间距
              runSpacing: 10.h, // 行与行之间的垂直间距
              children: historyList.map((length) {
                bool? isSelected = chooseList.contains(length);
                // bool? isSelected = chooseList.every((element) => historyList.contains(element));
                return GestureDetector(
                  onTap: () {
                    // 处理点击事件
                    setState(() {
                      if (isSelected) {
                        //如果已经被选中，则移除
                        chooseList.remove(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                      } else  {
                        // 如果未被选中且未达到最大选择数量，则添加
                        chooseList.add(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                      }
                    });
                  },
                  child: Material(
                    elevation: 0.1, // 设置边框效果
                    borderRadius: BorderRadius.circular(10.0), // 设置边框圆角
                    color: isSelected?Color(0XFFFBECE4):MyColors.backgreyColor, // 设置背景色
                    child: Padding(
                      padding: EdgeInsets.only(left: 6.w,right: 6.w,top: 3.h,bottom: 3.h),
                      child: Text(
                        length,
                        style: TextStyle(color: isSelected?MyColors.themeColor:MyColors.textColor,fontSize: 14.sp),
                      ),
                    ),
                  ),

                );
              }).toList(),
            ),
          ),

          SizedBox(height: 8.h,),
          Text("货物相关",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
          SizedBox(height: 8.h,),
          Container(
            child:Wrap(
              spacing: 10.w, // 两个Container之间的水平间距
              runSpacing: 10.h, // 行与行之间的垂直间距
              children: aboutGoodsList.map((length) {
                bool? isSelected = chooseList.contains(length);

                return GestureDetector(
                  onTap: () {
                    // 处理点击事件
                    setState(() {
                      if (isSelected) {
                        //如果已经被选中，则移除
                        chooseList.remove(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                      } else  {
                        // 如果未被选中且未达到最大选择数量，则添加
                        chooseList.add(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                        // print(isChooseList);
                      }
                    });
                  },
                  child: Material(
                    elevation: 0.1, // 设置边框效果
                    borderRadius: BorderRadius.circular(10.0), // 设置边框圆角
                    color: isSelected?Color(0XFFFBECE4):MyColors.backgreyColor, // 设置背景色
                    child: Padding(
                      padding: EdgeInsets.only(left: 6.w,right: 6.w,top: 3.h,bottom: 3.h),
                      child: Text(
                        length,
                        style: TextStyle(color: isSelected?MyColors.themeColor:MyColors.textColor,fontSize: 14.sp),
                      ),
                    ),
                  ),

                );
              }).toList(),
            ),
          ),

          SizedBox(height: 8.h,),
          Text("用车相关",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
          SizedBox(height: 8.h,),
          Container(
            child:Wrap(
              spacing: 10.w, // 两个Container之间的水平间距
              runSpacing: 10.h, // 行与行之间的垂直间距
              children: aboutCarList.map((length) {
                bool? isSelected = chooseList.contains(length);

                return GestureDetector(
                  onTap: () {
                    // 处理点击事件
                    setState(() {
                      if (isSelected) {
                        //如果已经被选中，则移除
                        chooseList.remove(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                      } else  {
                        // 如果未被选中且未达到最大选择数量，则添加
                        chooseList.add(length);
                        remarkStr=chooseList.toString().replaceAll("[", "").replaceAll("]", "");
                        // print(isChooseList);
                      }
                    });
                  },
                  child: Material(
                    elevation: 0.1, // 设置边框效果
                    borderRadius: BorderRadius.circular(10.0), // 设置边框圆角
                    color: isSelected?Color(0XFFFBECE4):MyColors.backgreyColor, // 设置背景色
                    child: Padding(
                      padding: EdgeInsets.only(left: 6.w,right: 6.w,top: 3.h,bottom: 3.h),
                      child: Text(
                        length,
                        style: TextStyle(color: isSelected?MyColors.themeColor:MyColors.textColor,fontSize: 14.sp),
                      ),
                    ),
                  ),

                );
              }).toList(),
            ),
          ),

        ],
      ),
    );
  }
}

class DespoitAlertShow extends StatefulWidget {
  const DespoitAlertShow({super.key});

  @override
  State<DespoitAlertShow> createState() => _DespoitAlertShowState();
}

class _DespoitAlertShowState extends State<DespoitAlertShow> {

  int alertCheck=1;
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(10))),
        width: 300.w,
        height: 260.h,
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Column(
                  children: [
                    TextButton(onPressed: (){
                      setState(() {
                        alertCheck=1;
                      });
                    }, child:  Text("退还流程",style: TextStyle (fontWeight:alertCheck==1? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: alertCheck==1?16.sp:14.sp),),),
                    Container(height: 2.h,width: 27.w,color:alertCheck==1?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
                  ],
                ),
                Column(
                  children: [
                    TextButton(onPressed: (){
                      setState(() {
                        alertCheck=2;
                      });
                    }, child:  Text("不退还流程",style:TextStyle (fontWeight:alertCheck==2? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: alertCheck==2?16.sp:14.sp),),),
                    Container(height: 2.h,width: 27.w,color:alertCheck==2?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
                  ],
                ),
              ],
            ),
            Divider(height: 1.h,color: MyColors.backgreyColor,),
            SizedBox(height: 10.h,),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Column(
                  children: [
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "1",
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                    Container(color: Colors.black,width: 0.5.w,height: 15.h,),
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "2",
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                    Container(color: Colors.black,width: 0.5.w,height: 15.h,),
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "3",
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),

                  ],
                ),
              SizedBox(width: 8.w,),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(alertCheck==1? "司机订货时支付订金到平台":"司机订货时支付订金到平台",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                  SizedBox(height: 15.h,),
                  Text(alertCheck==1? "货主点击“确认收货”":"司机点击“已装货”",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                  SizedBox(height: 15.h,),
                  Text(alertCheck==1? "平台将订金退还给司机":"平台将订金支付到货主钱包",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                ],
              ),
              ],
            ),
            SizedBox(height: 10.h,),
            Container(
              padding: EdgeInsets.only(left: 40.w,right: 40.w),
              child: Text(alertCheck==1? "若您未点击'确认收货'，平台将在最晚装货时间7天内将订金退还给司机":"若司机未点击”已装货“，平台将在最晚装货时间7天内将订金支付给您",style: TextStyle(color: MyColors.hintColor,decoration: TextDecoration.none,fontSize: 12.sp),)
            ),
            SizedBox(height: 15.h,),

              Container(
                padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                width: 280.w,
                color:Color.fromRGBO(255, 244, 229, 1) ,
                child:  RichText(
                  text: TextSpan(children: [

                    TextSpan(
                        text: '具体订金规则详情，请见 ',
                        style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                    TextSpan(
                        text: '《速配货平台订金担保规则》》',

                        style: TextStyle(fontSize: 12.sp,decoration: TextDecoration.none, color: Colors.blue),
                        recognizer: TapGestureRecognizer()
                          ..onTap = () {
                            Navigator.push( context, FadeRoute(page:ProtocolDisplay(id: "1805853468734525442",)));
                          }),

                  ]),
                ),
              ),
            TextButton(onPressed: (){
              Navigator.pop(context);
            }, child: Text("我知道了",style: TextStyle(color: MyColors.themeColor,decoration: TextDecoration.none,fontSize: 16.sp
            ),)),
          ],
        ),
      ),
    );
  }
}

class MyBidSheet extends StatefulWidget {
  const MyBidSheet({super.key, required this.goodsWeight, required this.goodsValume, required this.freight, required this.BidType});
  final String goodsWeight;
  final String goodsValume;
  final String freight;
  final int BidType;
  @override
  State<MyBidSheet> createState() => _MyBidSheetState();
}

class _MyBidSheetState extends State<MyBidSheet> {
  String MyBid="";
  List<String> BidTypeList=["趟","吨","方"];
  int BidType =0;
  int packIndex =-1;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    MyBid=widget.freight;
    BidType=widget.BidType;
  }
 late TextEditingController _freightEditingController = TextEditingController(text: MyBid);
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 20.w,right: 20.w),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10))),
      height: 500.h,
      child: Column(
        children: [
          SizedBox(height: 10.h,),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              TextButton(onPressed: (){Navigator.pop(context);}, child: Text("取消     ",style: TextStyle(color: Colors.black,fontSize: 14.sp),),),

              Text("我的出价",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
              TextButton(onPressed: (){ if (MyBid==""&&BidType==-1)
                BrnToast.show("请填写运费", context);
              else

                Navigator.pop(context, [MyBid,BidType]);}, child: Text("     确认",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),),


            ],
          ),
          SizedBox(height: 15.h,),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                  Text("请确定计价单位",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                ],
              ),
              Row(
                children: [
                  BrnSmallMainButton(
                    title: '趟',
                    width: 40.w,
                    fontSize: 14.sp,
                    fontWeight: FontWeight.w100,
                    textColor:BidType==0?MyColors.themeColor: Colors.black,
                    bgColor:BidType==0?Color.fromRGBO(251, 236, 228, 1) :MyColors.backgreyColor,
                    onTap: () {
                      setState(() {
                        BidType =0;
                        packIndex=0;
                        print(widget.goodsWeight+"   "+widget.goodsValume);
                      });

                    },
                  ),
                  SizedBox(width: 4.w,),
                  if(widget.goodsWeight!="")
                    BrnSmallMainButton(
                      title: '吨',
                      width: 40.w,
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w100,
                      textColor:BidType==2?MyColors.themeColor: Colors.black,
                      bgColor:BidType==2?Color.fromRGBO(251, 236, 228, 1) :MyColors.backgreyColor,
                      onTap: () {
                        setState(() {
                          BidType =2;
                          packIndex=2;
                        });

                      },
                    ),
                  SizedBox(width: 4.w,),
                  if(widget.goodsValume!="")
                    BrnSmallMainButton(
                      title: '方',
                      width: 40.w,
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w100,
                      textColor:BidType==1?MyColors.themeColor: Colors.black,
                      bgColor:BidType==1?Color.fromRGBO(251, 236, 228, 1) :MyColors.backgreyColor,
                      onTap: () {
                        setState(() {
                          BidType =1;
                          packIndex=1;
                        });

                      },
                    ),
                ],
              )

            ],
          ),
          SizedBox(height: 15.h,),
          Container(
            height: 44.h,
            padding: EdgeInsets.only(left: 15.w,right: 15.w),
            decoration: BoxDecoration(
                color: MyColors.backgreyColor,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text("运费",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                    SizedBox(width: 20.w,),
                    Container(width: 1.w,height: 20.h,color: MyColors.hintColor,),
                  ],
                ),
                Row(
                  children: [
                    Container(
                      width:100.w,
                      height: 30.h,
                      child:  TextField(
                        controller: _freightEditingController,
                        decoration: InputDecoration(
                          hintText: '',
                          hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                          filled: true,
                          fillColor: MyColors.backgreyColor,
                          border: InputBorder.none,
                          alignLabelWithHint: true,
                          contentPadding: EdgeInsets.symmetric(vertical: 8.0.h, horizontal: 0.0.w),
                        ),
                        keyboardType: TextInputType.number,
                        textAlign: TextAlign.right,
                        style: TextStyle(color: Colors.black,fontSize: 14.sp),
                        onChanged: (value) {
                          setState(() {
                            print(value);
                            MyBid =value;
                          });
                        },
                      ),
                    ),
                    SizedBox(width: 20.w,),
                    Text(BidType==0? "元/趟":BidType==2?"元/吨":"元/方",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                  ],
                ),
              ],
            ),
          ),
          SizedBox(height: 10.h,),
          Row(
            children: [
              Text("总费用为：",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
              if (BidType==0)
                Text("¥" + MyBid, style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
              if(BidType==2&&MyBid!="")
                Text("¥"+(double.parse(MyBid)*double.parse(widget.goodsWeight)).toStringAsFixed(2),style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
              if(BidType==1&&MyBid!="")
                Text("¥"+ (double.parse(MyBid)*double.parse(widget.goodsValume)).toStringAsFixed(2),style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
            ],
          )
        ],
      ),
    );
  }
}